﻿using fabao.SqlSugar;
using Material.Domain.Entities;
using Material.Domain.IRepository;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Material.Infrastructure.Repository
{
    public class MaterialRepository: IMaterialRepository
    {
        private readonly IRepository<TzMaterial> _client;
        public MaterialRepository(IRepository<TzMaterial> client)
        {
            _client = client;
        }

        /// <summary>
        /// 获取分页列表
        /// </summary>
        /// <param name="totalConut"></param>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public async Task<List<TzMaterial>> GetPageListAsync(RefAsync<int> totalConut, int page, int limit) 
        {
            return await _client.Context.Queryable<TzMaterial>()
               .Where(a => a.isDel == 0)
               .OrderByDescending(a => a.createTime)
              .ToOffsetPageAsync(page, limit, totalConut);
        }
    }
}
